package com.demo.jianjunhuang.activitylifecycle;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements OnClickListener {

  private Button dialog_intent_btn;
  private Button normal_intent_btn;
  private Button launch_mode_btn;

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();
    initListener();
  }

  private void initView() {
    launch_mode_btn = (Button) findViewById(R.id.btn_launch_mode);
    dialog_intent_btn = (Button) findViewById(R.id.btn_dialog_intent);
    normal_intent_btn = (Button) findViewById(R.id.btn_normal_intent);
  }

  private void initListener() {
    launch_mode_btn.setOnClickListener(this);
    dialog_intent_btn.setOnClickListener(this);
    normal_intent_btn.setOnClickListener(this);
  }

  @Override public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btn_dialog_intent: {
        Intent intent = new Intent(this, DialogActivity.class);
        startActivity(intent);
        break;
      }
      case R.id.btn_normal_intent: {
        Intent intent = new Intent(this, NormalActivity.class);
        startActivity(intent);
        break;
      }
      case R.id.btn_launch_mode: {
        Intent intent = new Intent(this, FirstActivity.class);
        startActivity(intent);
        break;
      }
    }
  }
}
